/*
 * @Date: 2021-09-12 19:21:05
 * @Author: Acckno1
 * @LastEditTime: 2021-09-12 19:21:45
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 510;

int n, m, c1, c2;
int g[N][N];
int dist[N], nums[N], cnt[N], tot[N];
bool st[N];

void Dijkstra() {
    memset(dist, 0x3f, sizeof dist);
    dist[c1] = 0, cnt[c1] = 1, tot[c1] = nums[c1];
    for (int i = 0; i < n; i ++ ) {
        int t = -1;
        for (int j = 0; j < n; j ++ )
            if (!st[j] && (t == -1 || dist[t] > dist[j]))
                t = j;
        st[t] = true;
        for (int j = 0; j < n; j ++ ) {
            if (dist[t] + g[t][j] < dist[j]) {
                dist[j] = dist[t] + g[t][j];
                cnt[j] = cnt[t];
                tot[j] = tot[t] + nums[j];
            } else if (dist[t] + g[t][j] == dist[j]) {
                cnt[j] += cnt[t];
                tot[j] = max(tot[t] + nums[j], tot[j]);
            }
        }
    }
}

int main() {
    memset(g, 0x3f, sizeof g);
    scanf("%d%d%d%d", &n, &m, &c1, &c2);
    for (int i = 0; i < n; i ++) 
        scanf("%d", &nums[i]);
    for (int i = 1; i <= m; i ++ ) {
        int a, b, w;
        scanf("%d%d%d", &a, &b, &w);
        g[a][b] = g[b][a] = w;
    }
    
    Dijkstra();
    
    cout << cnt[c2] << " " << tot[c2] << endl; 
    return 0;
}